<?php

/**
 * Beca form base class.
 *
 * @method Beca getObject() Returns the current form's model object
 *
 * @package    auip
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseBecaForm extends BaseFormDoctrine
{
  public function setup()
  {    
      $this->setWidgets(array(
      'id'                    => new sfWidgetFormInputHidden(),
      'logo'                  => new sfWidgetFormInputFile(array('label' => 'Cargar Imagen')),
      //'logo'                  => new sfWidgetFormInputFileEditable(array('label'=> 'Cargar Imagen','file_src'  => '/uploads/logos/'.$this->getObject()->getLogo(), 'is_image'  => true, 'edit_mode' => $this->isNew(),'template'=> "<div class='clase_inputfile' title='Seleccion'>%input%<br/></div> <div id='valor'>%file%</div>"), 
        //                                                           array('name'=>'adjunto', 'id'=>'adjunto', 'class'=>'cambia_input_file')),
      //'nombre'                => new sfWidgetFormInputText(array(), array('maxlength' => '255', 'cols'=> '70')),
      'nombre'                => new sfWidgetFormTextarea(array(), array('class'=>'nombre','rows' => '2', 'cols' => '90')),      
      'descripcion'           => new sfWidgetFormTextarea(array(), array('class'=>'descripcion','rows' => '8', 'cols' => '90', 'maxlength' => '1000')),
      'dirigido_a'            => new sfWidgetFormInputText(array(), array('class'=>'dirigido','maxlength' => '255')),
      'requisitos'            => new sfWidgetFormTextarea(array(), array('class'=>'requisitos','rows' => '8', 'cols' => '90')),      
      'plazo'                 => new sfWidgetFormInputText(array(), array('class'=>'plazo','maxlength' => '100', 'onclick'=>"nada(this)")),
      'fecha_inicio'          => new sfWidgetFormInputText(array(), array('class'=>'fecha_inicio','maxlength' => '10', 'id'=>'fecha_inicio', 'readonly'=>'true')),      
      'fecha_fin'             => new sfWidgetFormInputText(array(), array('class'=>'fecha_fin','maxlength' => '10', 'id'=>'fecha_fin', 'readonly'=>'true', 'onchange'=>'validaFecha()')),      
      'universidad_ofrece_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Universidad'), 'add_empty' => false, 'order_by' => array('nombre','asc')), array('class'=>'universidad')),
    ));
    
    $this->setValidators(array(
      'id'                    => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      //'logo'                  => new sfValidatorFile(array('required'=> false, 'path'=> sfConfig::get('sf_upload_dir').'/logos','mime_types' => 'web_images')),      
      'logo'                  => new sfValidatorFile(array('required'=> false, 'path'=> sfConfig::get('sf_upload_dir').'/logos', 'namefile'=>'logo', 'mime_categories'=>'web_images')),
      'nombre'                => new sfValidatorString(array('required' => true)),
      'descripcion'           => new sfValidatorString(array('required' => false)),
      'dirigido_a'            => new sfValidatorString(array('required' => false)),
      'requisitos'            => new sfValidatorString(array('required' => false)),
      'plazo'                 => new sfValidatorString(array('required' => false)),
      'fecha_inicio'          => new sfValidatorDate(),
      'fecha_fin'             => new sfValidatorDate(),
      'universidad_ofrece_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Universidad'))),      
    ));

    $this->widgetSchema->setNameFormat('beca[%s]');    

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Beca';
  }

}
//
